

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Cheney">
  <meta name="keywords" content="Coding">
  
    <meta name="description" content="在密码学中，恺撒密码（英语：Caesarcipher），或称恺撒加密、恺撒变换、变换加密，是一种最简单且最广为人知的加密技术。它是一种替换加密的技术，明文中的所有字母都在字母表上向后（或向前）按照一个固定数目进行偏移后被替换成密文.">
<meta property="og:type" content="article">
<meta property="og:title" content="Caesar密码的生成与破解">
<meta property="og:url" content="https://cheney822.gitee.io/2022/03/03/Caesar%E5%AF%86%E7%A0%81%E7%9A%84%E7%94%9F%E6%88%90%E4%B8%8E%E7%A0%B4%E8%A7%A3/index.html">
<meta property="og:site_name" content="Cheney blog">
<meta property="og:description" content="在密码学中，恺撒密码（英语：Caesarcipher），或称恺撒加密、恺撒变换、变换加密，是一种最简单且最广为人知的加密技术。它是一种替换加密的技术，明文中的所有字母都在字母表上向后（或向前）按照一个固定数目进行偏移后被替换成密文.">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-03-03T13:00:00.000Z">
<meta property="article:modified_time" content="2022-04-05T13:14:32.071Z">
<meta property="article:author" content="Cheney">
<meta property="article:tag" content="密码">
<meta property="article:tag" content="Python">
<meta name="twitter:card" content="summary_large_image">
  
  
  <title>Caesar密码的生成与破解 - Cheney blog</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hint.css@2/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"cheney822.gitee.io","root":"/","version":"1.8.14","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":1},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.4.1"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Cheney Blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('https://imgbed.cheney.cc/Blog_config/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="Caesar密码的生成与破解">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2022-03-03 21:00" pubdate>
        2022年3月3日 晚上
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      4.3k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      22 分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Caesar密码的生成与破解</h1>
            
            <div class="markdown-body">
              <h2 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h2><p>在密码学中，恺撒密码（英语：Caesarcipher），或称恺撒加密、恺撒变换、变换加密，是一种最简单且最广为人知的加密技术。它是一种替换加密的技术，明文中的所有字母都在字母表上向后（或向前）按照一个固定数目进行偏移后被替换成密文。例如，当偏移量是3的时候，所有的字母A将被替换成D，B变成E，以此类推。这个加密方法是以罗马共和时期恺撒的名字命名的，当年恺撒曾用此方法与其将军们进行联系。</p>
<p>恺撒密码的替换方法是通过排列明文和密文字母表，密文字母表示通过将明文字母表向左或向右移动一个固定数目的位置。例如，当偏移量是左移3的时候（解密时的密钥就是3）：</p>
<blockquote>
<p>明文字母表：ABCDEFGHIJKLMNOPQRSTUVWXYZ ；<br>密文字母表：DEFGHIJKLMNOPQRSTUVWXYZABC。</p>
</blockquote>
<p>使用时，加密者查找明文字母表中需要加密的消息中的每一个字母所在位置，并且写下密文字母表中对应的字母。需要解密的人则根据事先已知的密钥反过来操作，得到原来的明文。例如：</p>
<blockquote>
<p>明文：THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG ；<br>密文：WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ。</p>
</blockquote>
<h2 id="思路"><a href="#思路" class="headerlink" title="思路"></a>思路</h2><h3 id="加密"><a href="#加密" class="headerlink" title="加密"></a>加密</h3><ul>
<li>首先读入密钥和明文</li>
<li>然后将明文(字母)逐位循环右移k位</li>
<li>输出密文</li>
</ul>
<h3 id="解密"><a href="#解密" class="headerlink" title="解密"></a>解密</h3><ul>
<li>首先读入密文</li>
<li>然后穷举所有可能的密钥(26种)</li>
<li>对于每一个密钥对密文做循化左移</li>
<li>对处理后的句子做分割,分隔符是处理字母以外的其他符号</li>
<li>判断得到的单词在字典里面是否能找到,并统计每一句里面的个数</li>
<li>最后含有最多可识别单词的句子即为明文</li>
<li>输出破解出明文和密钥</li>
</ul>
<h2 id="实现"><a href="#实现" class="headerlink" title="实现"></a>实现</h2><h3 id="加密-1"><a href="#加密-1" class="headerlink" title="加密"></a>加密</h3><figure class="highlight python"><table><tr><td class="gutter"><div class="code-wrapper"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></div></td><td class="code"><pre><code class="hljs python"><span class="hljs-string">&#x27;&#x27;&#x27;</span><br><span class="hljs-string">此程序用来做Caesar密码的加密工作</span><br><span class="hljs-string">输入明文和密钥则可以生成对应的密文</span><br><span class="hljs-string">原理是：明文的每一位字符都在字母表上循环右移key位</span><br><span class="hljs-string">&#x27;&#x27;&#x27;</span><br><br>key = <span class="hljs-built_in">int</span>(<span class="hljs-built_in">input</span>(<span class="hljs-string">&quot;请输入密钥(0~25之间的整数):\t&quot;</span>))<br><span class="hljs-comment"># key=1</span><br><br>plaintext = <span class="hljs-built_in">input</span>(<span class="hljs-string">&quot;请输入要加密的明文:\t&quot;</span>)<br><span class="hljs-comment"># plaintext=&quot;abcxyz ABCXYZ&quot; # 测试用</span><br><br><span class="hljs-comment"># 此处可添加key和text的格式检查</span><br><br><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;\n您输入的key为:&quot;</span>,key)<br><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;您输入的明文是:&quot;</span>, plaintext, <span class="hljs-string">&quot;\n&quot;</span>) <span class="hljs-comment"># 输入的明文可以包含任意非换行符的字符 但除大小写字母外 均被认为是分隔符</span><br><br>secrettext = []  <span class="hljs-comment"># 字符串不可修改 用列表转换而来</span><br><span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> plaintext:  <span class="hljs-comment"># 依次处理字符串中的每个字符</span><br>    <span class="hljs-keyword">if</span> i.isalpha():  <span class="hljs-comment"># 是字母才处理</span><br>        <span class="hljs-keyword">if</span> i.islower():  <span class="hljs-comment"># 判断是小写字母</span><br>            i = <span class="hljs-built_in">chr</span>((<span class="hljs-built_in">ord</span>(i) - <span class="hljs-number">97</span> - key) % <span class="hljs-number">26</span> + <span class="hljs-number">97</span>)  <span class="hljs-comment"># 小写字母 循环右移 key位</span><br>        <span class="hljs-keyword">else</span>:<br>            i = <span class="hljs-built_in">chr</span>((<span class="hljs-built_in">ord</span>(i) - <span class="hljs-number">65</span> - key) % <span class="hljs-number">26</span> + <span class="hljs-number">65</span>)  <span class="hljs-comment"># 大写字母 循环右移 key位</span><br><br>    secrettext.append(i)<br>secrettext=<span class="hljs-string">&quot;&quot;</span>.join(secrettext)  <span class="hljs-comment"># 列表转换成字符串</span><br><br><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;变化后的密文是:&quot;</span>,secrettext)<br></code></pre></td></tr></table></figure>

<h3 id="解密-1"><a href="#解密-1" class="headerlink" title="解密"></a>解密</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-string">&#x27;&#x27;&#x27;</span><br><span class="hljs-string">此程序用来做Caesar密码的解密工作</span><br><span class="hljs-string">输密文可以破解出对应的密钥和明文</span><br><span class="hljs-string">原理是：暴力穷举所有可能的key 对照字典查看哪种情况的文本最规范 则认为其是答案</span><br><span class="hljs-string">&#x27;&#x27;&#x27;</span><br><br><br><span class="hljs-keyword">import</span> enchant<br><br>d = enchant.<span class="hljs-type">Dict</span>(<span class="hljs-string">&quot;en_US&quot;</span>)  <span class="hljs-comment">#用来查询的字典</span><br>real_key = <span class="hljs-number">0</span>  <span class="hljs-comment"># 密钥</span><br>plaintext = <span class="hljs-string">&quot;&quot;</span>  <span class="hljs-comment"># 明文</span><br><br>secrettext = <span class="hljs-built_in">input</span>(<span class="hljs-string">&quot;请输入要解密的密文:\t&quot;</span>)<br><br><br>tmp = <span class="hljs-number">0</span><br><span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">26</span>):<br>    in_plaintext = []<br>    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> secrettext:  <span class="hljs-comment"># 依次处理字符串中的每个字符</span><br>        <span class="hljs-keyword">if</span> i.isalpha():  <span class="hljs-comment"># 是字母才处理</span><br>            <span class="hljs-keyword">if</span> i.islower():  <span class="hljs-comment"># 判断是小写字母</span><br>                i = <span class="hljs-built_in">chr</span>((<span class="hljs-built_in">ord</span>(i) - <span class="hljs-number">97</span> + key) % <span class="hljs-number">26</span> + <span class="hljs-number">97</span>)<br>            <span class="hljs-keyword">else</span>:<br>                i = <span class="hljs-built_in">chr</span>((<span class="hljs-built_in">ord</span>(i) - <span class="hljs-number">65</span> + key) % <span class="hljs-number">26</span> + <span class="hljs-number">65</span>)<br>        <span class="hljs-keyword">else</span>:<br>            i = <span class="hljs-string">&quot; &quot;</span>  <span class="hljs-comment"># 不是字母的统一当作界符 并用空格统一替换</span><br><br>        in_plaintext.append(i)<br>    in_plaintext = <span class="hljs-string">&quot;&quot;</span>.join(in_plaintext)<br>    in_plaintext_s = in_plaintext.split(<span class="hljs-string">&quot; &quot;</span>)  <span class="hljs-comment"># 以空格区分单词</span><br><br>    accuracy = <span class="hljs-number">0</span>  <span class="hljs-comment"># 命中率 转换成明文之后 句子中可识别的单词</span><br>    <span class="hljs-keyword">for</span> word <span class="hljs-keyword">in</span> in_plaintext_s:<br>        <span class="hljs-keyword">if</span> word != <span class="hljs-string">&quot;&quot;</span>:<br>            accuracy += d.check(word)  <span class="hljs-comment"># 在词典中查询单词是否存在</span><br><br>    <span class="hljs-keyword">if</span> accuracy &gt; tmp:  <span class="hljs-comment"># 找到命中率最高的一个key 即为最终答案</span><br>        tmp = accuracy<br>        real_key = key<br>        plaintext = in_plaintext<br>    <span class="hljs-comment"># 下面输出每个key 对应的命中率 以及翻译出的明文 不需要可以注释掉</span><br>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;key:&quot;</span>, <span class="hljs-built_in">str</span>(key).center(<span class="hljs-number">3</span>, <span class="hljs-string">&quot; &quot;</span>), <span class="hljs-string">&quot;\taccuracy:&quot;</span>, accuracy, <span class="hljs-string">&quot;\tplaintext: &quot;</span>, in_plaintext)<br><br><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;\nkey:&quot;</span>, real_key, <span class="hljs-string">&quot;\nreal_plaintext:&quot;</span>, plaintext)<br><br></code></pre></td></tr></table></figure>

<h2 id="测试"><a href="#测试" class="headerlink" title="测试"></a>测试</h2><h3 id="加密-2"><a href="#加密-2" class="headerlink" title="加密"></a>加密</h3><figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs makefile">root@xxx <span class="hljs-comment"># python3 Caesar_make.py </span><br><span class="hljs-section">请输入密钥(0~25之间的整数):	3</span><br><span class="hljs-section">请输入要加密的明文:	Love what you do, Follow your heart.</span><br><br><span class="hljs-section">您输入的key为: 3</span><br><span class="hljs-section">您输入的明文是: Love what you do, Follow your heart. </span><br><br><span class="hljs-section">变化后的密文是: Ilsb texq vlr al, Cliilt vlro ebxoq.</span><br></code></pre></td></tr></table></figure>

<p>可见程序正确的将明文进行了加密，区分出大小写字母以及其他符号。</p>
<h3 id="解密-2"><a href="#解密-2" class="headerlink" title="解密"></a>解密</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><code class="hljs css">root<span class="hljs-keyword">@xxx</span> # python3 Caesar_solve.py <br>请输入要解密的密文:	Ilsb texq vlr al, Cliilt vlro ebxoq.<br><span class="hljs-attribute">key</span>:  <span class="hljs-number">0</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Ilsb texq vlr al  Cliilt vlro ebxoq <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">1</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Jmtc ufyr wms bm  Dmjjmu wmsp fcypr <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">2</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Knud vgzs xnt cn  Enkknv xntq gdzqs <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">3</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">7</span> 	<span class="hljs-attribute">plaintext</span>:  Love what you do  Follow your heart <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">4</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Mpwf xibu zpv ep  Gpmmpx zpvs ifbsu <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">5</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Nqxg yjcv aqw fq  Hqnnqy aqwt jgctv <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">6</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">1</span> 	<span class="hljs-attribute">plaintext</span>:  Oryh zkdw brx gr  Iroorz brxu khduw <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">7</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Pszi alex csy hs  Jsppsa csyv lievx <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">8</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">1</span> 	<span class="hljs-attribute">plaintext</span>:  Qtaj bmfy dtz it  Ktqqtb dtzw mjfwy <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">9</span>  	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Rubk cngz eua ju  Lurruc euax nkgxz <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">10</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Svcl doha fvb kv  Mvssvd fvby olhya <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">11</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Twdm epib gwc lw  Nwttwe gwcz pmizb <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">12</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Uxen fqjc hxd mx  Oxuuxf hxda qnjac <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">13</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Vyfo grkd iye ny  Pyvvyg iyeb rokbd <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">14</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">1</span> 	<span class="hljs-attribute">plaintext</span>:  Wzgp hsle jzf oz  Qzwwzh jzfc splce <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">15</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">1</span> 	<span class="hljs-attribute">plaintext</span>:  Xahq itmf kag pa  Raxxai kagd tqmdf <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">16</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Ybir jung lbh qb  Sbyybj lbhe urneg <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">17</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Zcjs kvoh mci rc  Tczzck mcif vsofh <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">18</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Adkt lwpi ndj sd  Udaadl ndjg wtpgi <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">19</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Belu mxqj oek te  Vebbem oekh xuqhj <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">20</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Cfmv nyrk pfl uf  Wfccfn pfli yvrik <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">21</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Dgnw ozsl qgm vg  Xgddgo qgmj zwsjl <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">22</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Ehox patm rhn wh  Yheehp rhnk axtkm <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">23</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">1</span> 	<span class="hljs-attribute">plaintext</span>:  Fipy qbun sio xi  Ziffiq siol byuln <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">24</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Gjqz rcvo tjp yj  Ajggjr tjpm czvmo <br><span class="hljs-attribute">key</span>:  <span class="hljs-number">25</span> 	<span class="hljs-attribute">accuracy</span>: <span class="hljs-number">0</span> 	<span class="hljs-attribute">plaintext</span>:  Hkra sdwp ukq zk  Bkhhks ukqn dawnp <br><br><span class="hljs-attribute">key</span>: <span class="hljs-number">3</span> <br>real_<span class="hljs-attribute">plaintext</span>: Love what you do  Follow your heart <br><br></code></pre></td></tr></table></figure>

<p>可见程序正确进行了解密，获得的密钥与明文与真实情况相同。</p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/%E5%AE%89%E5%85%A8/">安全</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/%E5%AF%86%E7%A0%81/">密码</a>
                    
                      <a class="hover-with-bg" href="/tags/Python/">Python</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/03/05/Nmap%E5%B7%A5%E5%85%B7%E7%9A%84%E5%AE%89%E8%A3%85%E4%B8%8E%E4%BD%BF%E7%94%A8/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Nmap工具的安装与实验(网络扫描)</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/10/04/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD__GAN%E6%89%8B%E5%86%99%E4%BD%93%E7%94%9F%E6%88%90(MINIST)/">
                        <span class="hidden-mobile">GAN手写体生成(MINIST)</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://cheney822.gitee.io/" target="_blank" rel="nofollow noopener"><span>备用网址</span></a> 
  </div>
  

  
  <!-- 备案信息 -->
  <div class="beian">
    <span>
      <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
        皖ICP备2022002876号-1
      </a>
    </span>
    
  </div>


  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  






  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
